package com.sneakxy.mybatis.commons.repository.query;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;

import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.factory.ObjectFactory;
import org.apache.ibatis.reflection.property.PropertyTokenizer;
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

/**
 * 分页中间层，转移数据使用
 * @author 潜行的青衣
 */
public class MybatisPageTempImpl<T> implements Page<T>, Serializable, ObjectWrapper {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2949513943353304906L;
	
	private List<Object> content = new ArrayList<Object>();
	
	public MybatisPageTempImpl() {
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#get(org.apache.ibatis.reflection.property.PropertyTokenizer)
	 */
	@Override
	public Object get(PropertyTokenizer prop) {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#set(org.apache.ibatis.reflection.property.PropertyTokenizer, java.lang.Object)
	 */
	@Override
	public void set(PropertyTokenizer prop, Object value) {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#findProperty(java.lang.String, boolean)
	 */
	@Override
	public String findProperty(String name, boolean useCamelCaseMapping) {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#getGetterNames()
	 */
	@Override
	public String[] getGetterNames() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#getSetterNames()
	 */
	@Override
	public String[] getSetterNames() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#getSetterType(java.lang.String)
	 */
	@Override
	public Class<?> getSetterType(String name) {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#getGetterType(java.lang.String)
	 */
	@Override
	public Class<?> getGetterType(String name) {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#hasSetter(java.lang.String)
	 */
	@Override
	public boolean hasSetter(String name) {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#hasGetter(java.lang.String)
	 */
	@Override
	public boolean hasGetter(String name) {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#instantiatePropertyValue(java.lang.String, org.apache.ibatis.reflection.property.PropertyTokenizer, org.apache.ibatis.reflection.factory.ObjectFactory)
	 */
	@Override
	public MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory) {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#isCollection()
	 */
	@Override
	public boolean isCollection() {
		return true;
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#add(java.lang.Object)
	 */
	@Override
	public void add(Object element) {
		content.add(element);
	}

	/* (non-Javadoc)
	 * @see org.apache.ibatis.reflection.wrapper.ObjectWrapper#addAll(java.util.List)
	 */
	@Override
	public <E> void addAll(List<E> element) {
		content.addAll(element);
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#getNumber()
	 */
	@Override
	public int getNumber() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#getSize()
	 */
	@Override
	public int getSize() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#getNumberOfElements()
	 */
	@Override
	public int getNumberOfElements() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#getContent()
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<T> getContent() {
		return (List<T>) this.content;
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#hasContent()
	 */
	@Override
	public boolean hasContent() {
		return this.content.isEmpty();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#getSort()
	 */
	@Override
	public Sort getSort() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#isFirst()
	 */
	@Override
	public boolean isFirst() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#isLast()
	 */
	@Override
	public boolean isLast() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#hasNext()
	 */
	@Override
	public boolean hasNext() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#hasPrevious()
	 */
	@Override
	public boolean hasPrevious() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#nextPageable()
	 */
	@Override
	public Pageable nextPageable() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Slice#previousPageable()
	 */
	@Override
	public Pageable previousPageable() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see java.lang.Iterable#iterator()
	 */
	@Override
	public Iterator<T> iterator() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Page#getTotalPages()
	 */
	@Override
	public int getTotalPages() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Page#getTotalElements()
	 */
	@Override
	public long getTotalElements() {
		throw new UnsupportedOperationException();
	}

	/* (non-Javadoc)
	 * @see org.springframework.data.domain.Page#map(java.util.function.Function)
	 */
	@Override
	public <U> Page<U> map(Function<? super T, ? extends U> converter) {
		throw new UnsupportedOperationException();
	}

}
